package com.springboot.scala.controller

import org.springframework.web.bind.annotation.{GetMapping, RequestMapping, RequestParam, RestController}

/**
 * @author 筱筱
 * @date 2021-02-24 10:21
 *
 *       类说明：
 */
@RestController
@RequestMapping(Array("/sb_scala"))
class HsController {

    @GetMapping(Array("/hello_s"))
    def helloS(@RequestParam(value = "name", defaultValue = "Scala") name: String): String = {
        test(name)
    }

    def test(name: String): String = {
        val l = List(1, 2, 3, 4)

        val s = Set(1, 3, 5, 7)

        val m = Map("one" -> 1, "two" -> 2, "three" -> 3)

        val y = (10, "Runoob")

        val o: Option[Int] = Some(5)
        println(l)
        println(s)
        println("m------------" + m.get("one"))
        println(y)
        println(o)

        val iterator = l.iterator
        while (iterator.hasNext) {
            println(iterator.next())
        }

        "Hello " + name
    }
}
